home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / EntertheTroy.dxr / 00007_Player handlers.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  10.8 KB  |  338 lines

  1. on initializeplayer
  2.   global playerLocData, playerSO, playerInventory
  3.   playerLocData = [1, 0, point(100, 100), 0, 0, #Walk, #L, 1, 0, 0, 0, 0]
  4.   puppetSprite(playerSO, 1)
  5.   set the member of sprite playerSO to "player Orb"
  6.   set the ink of sprite playerSO to 36
  7.   sprite(playerSO).locZ = 200
  8.   sprite(playerSO).visible = 0
  9.   playerInventory[2] = 0
  10. end
  11.  
  12. on movePlayer
  13.   global playerLocData, terrainData_Type, playerViewpoint, screenDimensions, inputString, playerSO, screenTileSize, anchorViewPoint, monsterHitArea, monsterHarmArea, monsterSO, monsterData, playerHealth
  14.   hitSpikes = 0
  15.   anchorViewPoint = point(0, 0)
  16.   enemyHit = 0
  17.   playerHit = 0
  18.   if playerLocData[1] = 1 then
  19.     repeat with wmon = 1 to count(monsterHitArea)
  20.       if (inside(playerLocData[3] + point(0, 50), monsterHitArea[wmon]) = 1) and (playerLocData[2] = 0) then
  21.         enemyHit = wmon
  22.         next repeat
  23.       end if
  24.       if (inside(playerLocData[3] + point(0, 40), monsterHarmArea[wmon]) = 1) and (playerLocData[2] = 1) then
  25.         playerHit = 1
  26.         next repeat
  27.       end if
  28.       if (inside(playerLocData[3] + point(20, -40), monsterHarmArea[wmon]) = 1) and (playerLocData[10] = 0) then
  29.         playerHit = 1
  30.         next repeat
  31.       end if
  32.       if (inside(playerLocData[3] + point(-20, -40), monsterHarmArea[wmon]) = 1) and (playerLocData[10] = 0) then
  33.         playerHit = 1
  34.         next repeat
  35.       end if
  36.       if inside(playerLocData[3] + point(20, 0), monsterHarmArea[wmon]) = 1 then
  37.         playerHit = 1
  38.         next repeat
  39.       end if
  40.       if inside(playerLocData[3] + point(-20, 0), monsterHarmArea[wmon]) = 1 then
  41.         playerHit = 1
  42.       end if
  43.     end repeat
  44.   end if
  45.   if playerHit = 1 then
  46.     rpoint = playerLocData[3]
  47.     playerLocData[1] = 0
  48.   end if
  49.   if playerLocData[1] = 1 then
  50.     harvestinput()
  51.     if inputString[4] = 1 then
  52.       inputString[5] = 1
  53.     end if
  54.     playerLocData[11] = 0
  55.   else
  56.     inputString = [0, 0, 0, 0, 0]
  57.     playerLocData[11] = playerLocData[11] + 1
  58.   end if
  59.   if (playerLocData[2] = 1) and (inputString[5] = 1) then
  60.     playerLocData[5] = -30
  61.     playerLocData[2] = 0
  62.     playSound("jump SFX", 3)
  63.   else
  64.     if enemyHit <> 0 then
  65.       playerLocData[5] = -45
  66.       playerLocData[2] = 0
  67.       monsterData[enemyHit][5] = monsterData[enemyHit][5] + 1
  68.     else
  69.       if (playerLocData[2] = 0) and (inputString[5] = 0) then
  70.         if playerLocData[5] < -10 then
  71.           playerLocData[5] = -10
  72.         end if
  73.       end if
  74.     end if
  75.   end if
  76.   maxHSpeed = 10
  77.   if (inputString[1] = 1) and (playerLocData[10] = 0) then
  78.     playerLocData[4] = playerLocData[4] - 2
  79.     if playerLocData[4] < (0 - maxHSpeed) then
  80.       playerLocData[4] = 0 - maxHSpeed
  81.     end if
  82.     playerLocData[7] = #left
  83.     playerLocData[6] = #Run
  84.     anchorViewPoint[1] = -75
  85.   else
  86.     if (inputString[2] = 1) and (playerLocData[10] = 0) then
  87.       playerLocData[4] = playerLocData[4] + 2
  88.       if playerLocData[4] > maxHSpeed then
  89.         playerLocData[4] = maxHSpeed
  90.       end if
  91.       playerLocData[7] = #right
  92.       playerLocData[6] = #Run
  93.       anchorViewPoint[1] = 75
  94.     else
  95.       repeat with whichRep = 1 to 2
  96.         if playerLocData[4] > 0 then
  97.           playerLocData[4] = playerLocData[4] - 1
  98.           next repeat
  99.         end if
  100.         if playerLocData[4] < 0 then
  101.           playerLocData[4] = playerLocData[4] + 1
  102.         end if
  103.       end repeat
  104.       case playerLocData[7] of
  105.         #left:
  106.           anchorViewPoint[1] = -50
  107.         #right:
  108.           anchorViewPoint[1] = 50
  109.       end case
  110.       playerLocData[6] = #idle
  111.     end if
  112.   end if
  113.   checkWallState = 1
  114.   if playerLocData[4] > 0 then
  115.     groundTest = playerLocData[3] + point(25, 0)
  116.     spikeTest = playerLocData[3] + point(20, 0)
  117.     checkWallState = 1
  118.   else
  119.     if playerLocData[4] < 0 then
  120.       groundTest = playerLocData[3] - point(30, 0)
  121.       spikeTest = playerLocData[3] - point(25, 0)
  122.       checkWallState = 1
  123.     else
  124.       checkWallState = 0
  125.     end if
  126.   end if
  127.   if checkWallState = 1 then
  128.     testTheWall1 = checkSolidpoint(groundTest + point(0, 40))
  129.     testTheWall2 = checkSolidpoint(groundTest + point(0, 0))
  130.     testTheWall3 = checkSolidpoint(groundTest + point(0, -40))
  131.     testSpikeWall1 = checkSolidpoint(spikeTest + point(0, 30))
  132.     testSpikeWall2 = checkSolidpoint(spikeTest + point(0, 0))
  133.     testSpikeWall3 = checkSolidpoint(spikeTest + point(0, -30))
  134.     if (testSpikeWall1[2] = 10) or (testSpikeWall2[2] = 10) or (testSpikeWall3[2] = 10) then
  135.       hitSpikes = 1
  136.     end if
  137.     if (testSpikeWall1[2] = 11) or (testSpikeWall2[2] = 11) or (testSpikeWall3[2] = 11) then
  138.       hitSpikes = 1
  139.     end if
  140.     if (testTheWall1[1] = 1) or (testTheWall2[1] = 1) or (testTheWall3[1] = 1) then
  141.       playerLocData[4] = 0
  142.       playerLocData[3][1] = playerLocData[3][1] - (playerLocData[3][1] mod screenTileSize) + integer(screenTileSize / 2.0)
  143.     end if
  144.   end if
  145.   if playerLocData[2] = 0 then
  146.     playerLocData[5] = playerLocData[5] + 2
  147.     verticalMove = playerLocData[5]
  148.     if verticalMove < -15 then
  149.       verticalMove = -15
  150.     end if
  151.     if verticalMove > 15 then
  152.       verticalMove = 15
  153.     end if
  154.     playerLocData[3][2] = playerLocData[3][2] + verticalMove
  155.     if playerLocData[5] > 0 then
  156.       groundTest = playerLocData[3] + point(0, 50)
  157.       testTheGround1 = checkSolidpoint(groundTest + point(15, 0))
  158.       testTheGround2 = checkSolidpoint(groundTest + point(-15, 0))
  159.       testSpikeGround1 = checkSolidpoint(groundTest + point(10, 0))
  160.       testSpikeGround2 = checkSolidpoint(groundTest + point(-10, 0))
  161.       if (testSpikeGround1[2] = 10) or (testSpikeGround2[2] = 10) then
  162.         hitSpikes = 1
  163.       end if
  164.       if (testSpikeGround1[2] = 11) or (testSpikeGround2[2] = 11) then
  165.         hitSpikes = 1
  166.       end if
  167.       if (testTheGround1[1] = 1) or (testTheGround2[1] = 1) then
  168.         playerLocData[5] = 0
  169.         playerLocData[2] = 1
  170.         playerLocData[3][2] = playerLocData[3][2] - ((playerLocData[3][2] + 50) mod screenTileSize)
  171.       end if
  172.     else
  173.       groundTest = playerLocData[3] - point(0, 50)
  174.       testTheGround1 = checkSolidpoint(groundTest + point(15, 0))
  175.       testTheGround2 = checkSolidpoint(groundTest + point(-15, 0))
  176.       testSpikeGround1 = checkSolidpoint(groundTest + point(10, 0))
  177.       testSpikeGround2 = checkSolidpoint(groundTest + point(-10, 0))
  178.       if (testSpikeGround1[2] = 10) or (testSpikeGround2[2] = 10) then
  179.         hitSpikes = 1
  180.       end if
  181.       if (testSpikeGround1[2] = 11) or (testSpikeGround2[2] = 11) then
  182.         hitSpikes = 1
  183.       end if
  184.       if (testTheGround1[1] = 1) or (testTheGround2[1] = 1) then
  185.         punchBlock(groundTest)
  186.         playerLocData[5] = 0
  187.       end if
  188.     end if
  189.   end if
  190.   groundTest = playerLocData[3] + point(0, 50)
  191.   testTheGround1 = checkSolidpoint(groundTest + point(20, 0))
  192.   testTheGround2 = checkSolidpoint(groundTest + point(-20, 0))
  193.   testTheGround3 = checkSolidpoint(groundTest + point(0, -10))
  194.   if (testTheGround3[2] = 10) or (testTheGround3[2] = 11) then
  195.     hitSpikes = 1
  196.   end if
  197.   if (testTheGround1[1] = 0) and (testTheGround2[1] = 0) then
  198.     playerLocData[2] = 0
  199.     if playerLocData[5] >= 0 then
  200.       playerLocData[6] = #Fall
  201.     else
  202.       playerLocData[6] = #jump
  203.     end if
  204.   else
  205.     conveyRight = 0
  206.     conveyLeft = 0
  207.     case testTheGround1[2] of
  208.       2:
  209.         conveyRight = conveyRight + 1
  210.       3:
  211.         conveyLeft = conveyLeft + 1
  212.     end case
  213.     case testTheGround2[2] of
  214.       2:
  215.         conveyRight = conveyRight + 1
  216.       3:
  217.         conveyLeft = conveyLeft + 1
  218.     end case
  219.     case testTheGround3[2] of
  220.       2:
  221.         conveyRight = conveyRight + 1
  222.       3:
  223.         conveyLeft = conveyLeft + 1
  224.     end case
  225.     if conveyRight > conveyLeft then
  226.       playerLocData[3] = playerLocData[3] + point(3, 0)
  227.     else
  228.       if conveyRight < conveyLeft then
  229.         playerLocData[3] = playerLocData[3] - point(3, 0)
  230.       end if
  231.     end if
  232.   end if
  233.   if inputString[3] = 1 then
  234.     if playerLocData[10] < 3 then
  235.       playerLocData[10] = playerLocData[10] + 1
  236.     end if
  237.   else
  238.     if playerLocData[10] > 0 then
  239.       playerLocData[10] = playerLocData[10] - 1
  240.     end if
  241.   end if
  242.   if playerLocData[10] <> 0 then
  243.     playerLocData[6] = #Crouch
  244.   end if
  245.   playerLocData[3][1] = playerLocData[3][1] + playerLocData[4]
  246.   if hitSpikes = 1 then
  247.     playerLocData[1] = 0
  248.   end if
  249.   if playerLocData[12] > 1 then
  250.     playerLocData[1] = 1
  251.     playerLocData[12] = playerLocData[12] - 1
  252.     set the foreColor of sprite playerSO to random(255)
  253.   else
  254.     set the foreColor of sprite playerSO to 255
  255.     if playerLocData[1] = 0 then
  256.       if playerHealth > 1 then
  257.         playerLocData[1] = 1
  258.         playerLocData[12] = 40
  259.         playerHealth = playerHealth - 1
  260.         playSound("Lose Heart SFX", 5)
  261.         rpoint = playerLocData[3]
  262.       else
  263.         playerLocData[6] = #Dead
  264.       end if
  265.     end if
  266.   end if
  267.   case playerLocData[6] of
  268.     #Run:
  269.       playerLocData[9] = playerLocData[9] + 1
  270.       if playerLocData[9] > 1 then
  271.         playerLocData[8] = playerLocData[8] + 1
  272.         if playerLocData[8] > 4 then
  273.           playerLocData[8] = 1
  274.         end if
  275.         playerLocData[9] = 0
  276.       end if
  277.       membername = "Player " & "Normal" & " Walk" & string(playerLocData[8])
  278.     #idle:
  279.       membername = "Player " & "Normal" & " Idle"
  280.     #jump:
  281.       membername = "Player " & "Normal" & " Jump"
  282.     #Fall:
  283.       membername = "Player " & "Normal" & " Fall"
  284.     #Crouch:
  285.       membername = "Player " & "Normal" & " Crouch"
  286.     #Dead:
  287.       membername = "Player " & "Normal" & " Dead"
  288.   end case
  289.   case playerLocData[7] of
  290.     #left:
  291.       sprite(playerSO).flipH = 1
  292.     #right:
  293.       sprite(playerSO).flipH = 0
  294.   end case
  295.   if playerLocData[1] = 0 then
  296.     if playerLocData[11] < 45 then
  297.       if playerLocData[11] = 15 then
  298.         playSound("T-Roy Dies SFX", 5)
  299.       end if
  300.       set the loc of sprite playerSO to playerLocData[3] - playerViewpoint
  301.       set the member of sprite playerSO to membername
  302.     else
  303.       if playerLocData[11] = 45 then
  304.         addPickup(3, 5, playerLocData[3] + point(-25, 0), point((random(50) - 25) / 10.0, -2 - random(16)))
  305.         repeat with wAdd = 1 to 30
  306.           addPickup(3, random(4), playerLocData[3] + point(-25, 0), point((random(50) - 25) / 10.0, -2 - random(16)))
  307.         end repeat
  308.         sprite(playerSO).visible = 0
  309.       end if
  310.     end if
  311.   else
  312.     set the loc of sprite playerSO to playerLocData[3] - playerViewpoint
  313.     set the member of sprite playerSO to membername
  314.   end if
  315.   if inputString[3] = 1 then
  316.     anchorViewPoint[2] = 100
  317.   else
  318.     anchorViewPoint[2] = 0
  319.   end if
  320.   anchorViewPoint = anchorViewPoint - point(290, 250) + playerLocData[3]
  321. end
  322.  
  323. on setPMode modeType, modeFlip
  324.   global playerLocData
  325.   if (playerLocData[6] <> modeType) or (playerLocData[7] <> modeFlip) then
  326.     playerLocData[8] = 0
  327.     playerLocData[9] = 0
  328.   end if
  329.   playerLocData[6] = #modeType
  330.   playerLocData[7] = modeFlip
  331. end
  332.  
  333. on addScore scoreValue
  334.   global playerScore, levelScore, updateScoreDisplayNOW
  335.   levelScore = levelScore + scoreValue
  336.   updateScoreDisplayNOW = 1
  337. end
  338.